#include "StdAfx.h"
#include "ISocket.h"


bool  WSINIT(){
	WORD wVersionRequested;
	WSADATA wsaData;
	int err;
	wVersionRequested = MAKEWORD(1, 1);
	err = WSAStartup( wVersionRequested, &wsaData );
	if (err!=0) 
		return false;
	if (LOBYTE( wsaData.wVersion ) != 1 ||	HIBYTE( wsaData.wVersion ) != 1){
		WSACleanup( );
		return false;
	}
	return true; 

}

void WSUNINIT(){
	WSACleanup();
}

void GetSocketAddr(const char * host ,u_short port ,SOCKADDR_IN &addr){
	addr.sin_addr.S_un.S_addr=inet_addr(host);
	addr.sin_family=AF_INET;
	addr.sin_port=htons(port);
}